#pragma once

#include "IMesh.h"
#include "BoundingVolume.h"
#include <d3d9.h>


struct IDirect3DDevice9;
struct IDirect3DVertexBuffer9;
struct IDirect3DIndexBuffer9;
class CGraphicsController;


///////////////////////////////////////////////////////////////////////////////

class CCubeVertex
{
public:
   CCubeVertex(void) : m_coords(0, 0, 0), m_normal(0, 0, 0) {}
   CCubeVertex(float x, float y, float z) : m_coords(x, y, z), m_normal(0, 0, 0) {}
   CCubeVertex(float x, float y, float z, float nx, float ny, float nz) 
      : m_coords(x, y, z), m_normal(nx, ny, nz) {}

   CCubeVertex(float x, float y, float z, const D3DXVECTOR3& normal) 
      : m_coords(x, y, z), m_normal(normal) {}

   D3DXVECTOR3 m_coords;
   D3DXVECTOR3 m_normal;

   static DWORD FVF;
};

///////////////////////////////////////////////////////////////////////////////

class CCubeMesh : public IMesh
{
private:
   IDirect3DDevice9& m_d3Device;
   IDirect3DVertexBuffer9* m_vertexBuffer;
   IDirect3DIndexBuffer9* m_indexBuffer;
   UINT m_facesCount;
   AABoundingBox m_boundingBox;

public:
   CCubeMesh(CGraphicsController& graphicsController);
   ~CCubeMesh(void);

   void render();

   const AABoundingBox& getModelSpaceBoundingBox() const {return m_boundingBox;}
};
